GBML manual / Instances

object

Which object this instance is an instance of.

Left out on purpose. GBML does not offer this, and that is a choice. There is a better way, shown below. See On the GBA below.

Syntax

object: object (read-only)

Description

Would tell you which object an instance is an instance of, read back while the game runs. It would be handy for code that is handed some instance and needs to know what kind it is.

GBML leaves this out on purpose. An instance does not carry its object's name around while the game runs. You almost always know the kind already: from the event you are inside, or from the type a ref<obj> variable was declared with.

When you really do need to tell kinds apart while the game runs, give the object a variable that says what it is. Set that variable in the instance's creation code, then read it wherever you need it.

If what you have is a family of objects that share a parent, Objects and parents explains how they share variables and events.

On the GBA

Why not: an instance does not carry its object’s name around while the game runs. An ordinary variable can already do the same job, so nothing more is needed.

Use instead: give the object a variable that says what it is, and set it in the instance’s creation code. Then read that variable wherever you need to tell kinds apart.

See also: Objects and parentsinstance_create